﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="framecontainer" style="padding:5px">
        <div class="listcontainer">
            <div class="tableop">
                <table class="GridStyle" id="CloudGrid" keyid="RelationGuid" url="opSelectList" relationpageid="cloudpagination" otherparm="SearchParm" afterbind="AfterBindData">
                    <tr class="HeaderStyle">
                        <th scope="col" style="width: 10px;" field="index" rowalign="center">序</th>
                        <th scope="col" style="width: 100px;" field="JobTypeText" rowalign="left">兼职类型</th>
                        <th scope="col" field="JobContent" rowalign="left">兼职内容</th>
                        <th scope="col" field="function" functionname="GetSettingCheck" rowalign="center" style="width:80px">设置默认</th>
                        <th scope="col" style="width: 50px;" field="EditButton" functionname="SelectJob" rowalign="center">选择</th>
                    </tr>
                </table>
            </div>
            <div class="bottomop">
                <div class="pageop">
                    <ul class="pagination" id="cloudpagination"></ul>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            BindGrid();
        })
        function BindGrid() {
            BindCloudGrid($("#CloudGrid"))
        }

        function SearchParm() {
            return {
                "UserGuid": GetUrlParam("userguid")
            };
        }
        function AfterBindData() {
            $("jobcheckbox").each(function () {
                $(".jobcheckbox").each(function () {
                    $(this).removeAttr('checked');
                })
                $(this).attr("checked", "checked");
            })
        }

        function SelectJob(RowData) {
            var SetDeafault = $("#" + RowData.RelationGuid).prop('checked') ? "1" : "2";
            var param = { "UserGuid": GetUrlParam("userguid"), "RelationGuid": RowData.RelationGuid, "SetDeafault": SetDeafault, "UserJobGuid": RowData.UserJobGuid };
            CloudPost(param, GetRootPath() + "frame/home/changeUserJob", function (res) {
                if (res.code == 0) {
                    CloseDialog("OK");
                } else {
                    OpenFail(res.data)
                }
            })
        }

        function GetSettingCheck(RowData) {
            if (RowData.IsDefault) {
                return "<input class='jobcheckbox' type='checkbox' id='" + RowData.RelationGuid + "' checked change='JobCheckChange()'>"
            } else {
                return "<input class='jobcheckbox' type='checkbox' id='" + RowData.RelationGuid + "' change='JobCheckChange()'>"
            }
           
        }
    </script>
</body>
</html>
